package stores

import (
	"jvm/nzpJvm/instructions/base"
	"jvm/nzpJvm/runtime_area"
)

// 将操作数栈中一个int存入局部变量表指定索引位置
type ISTORE struct{ base.Index8Instruction }
type ISTORE_0 struct{ base.NoOperandsInstruction }
type ISTORE_1 struct{ base.NoOperandsInstruction }
type ISTORE_2 struct{ base.NoOperandsInstruction }
type ISTORE_3 struct{ base.NoOperandsInstruction }

func (self *ISTORE) Execute(frame *runtime_area.Frame) {
	_istore(frame, self.Index)
}
func (self *ISTORE_0) Execute(frame *runtime_area.Frame) {
	_istore(frame, 0)
}
func (self *ISTORE_1) Execute(frame *runtime_area.Frame) {
	_istore(frame, 1)
}
func (self *ISTORE_2) Execute(frame *runtime_area.Frame) {
	_istore(frame, 2)
}
func (self *ISTORE_3) Execute(frame *runtime_area.Frame) {
	_istore(frame, 3)
}
func _istore(frame *runtime_area.Frame, index uint) {
	// 从栈帧的操作数栈中出一个int值，
	aInt := frame.OperandStack().PopInt()
	// 保存到本地变量表中
	frame.LocalVars().SetInt(index,aInt)
}


